package com.lvyq.myplayer.util

import com.lvyq.myplayer.R
import com.lvyq.myplayer.base.BaseFragment
import com.lvyq.myplayer.ui.fragment.IndexFragment
import com.lvyq.myplayer.ui.fragment.MvFragment
import com.lvyq.myplayer.ui.fragment.UserCenterFragment
import com.lvyq.myplayer.ui.fragment.UserFragment
import com.lvyq.myplayer.ui.fragment.YueDanFragment

/**
 * 文件描述：FragmentUtil
 * 作者：lvyq
 * 创建时间：2025-02-13
 * 修改时间：2025-02-13
 */
class FragmentUtil private constructor(){//私有化构造方法

    //首页
    val indexFragment by lazy { IndexFragment() }
    val mvFragment by lazy { MvFragment() }
    val userFragment by lazy { UserFragment() }
    val userCenterFragment by lazy { UserCenterFragment() }
    val yueDanFragment by lazy { YueDanFragment() }
    companion object{
       val fragmentUtil by lazy { FragmentUtil() }
    }
    //根据tabId获取fragment

    fun  getFragment(tabId:Int): BaseFragment? {
            when(tabId){
                R.id.tab_index-> return indexFragment
               // R.id.tab_home-> return homeFragment
               //  R.id.tab_mv-> return  mvFragment
               // R.id.tab_song -> return yueDanFragment
                R.id.tab_song -> return userFragment
                R.id.tab_user -> return  userCenterFragment

            }
        //默认首页
        return indexFragment
    }
}